Skip to content

Commit

Permalink
[Cherry-pick] Allow ambient accessors to omit their types unde… (#36280)
Browse files Browse the repository at this point in the history
* Fix noImplicitAny check on ambient private getters (#33896)

* Fix scripts.

Co-authored-by: Klaus Meinhardt <klaus.meinhardt1@gmail.com>
  • Loading branch information
DanielRosenwasser and ajafff authored Jan 23, 2020
1 parent 0dbaef5 commit e0a286a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const mkdirp = require("mkdirp");
const del = require("del");
const File = require("vinyl");
const ts = require("../../lib/typescript");
const { default: chalk } = require("chalk");
const chalk = require("chalk");
const { spawn } = require("child_process");
const { CancellationToken, CancelError, Deferred } = require("prex");
const { Readable, Duplex } = require("stream");
Expand Down
2 changes: 1 addition & 1 deletion scripts/tslint/formatters/autolinkableStylishFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Lint from "tslint";
import chalk from "chalk";
import chalk = require("chalk");
import { sep } from "path";
function groupBy<T>(array: ReadonlyArray<T> | undefined, getGroupId: (elem: T, index: number) => number | string): T[][] {
if (!array) {
Expand Down
6 changes: 4 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5943,8 +5943,10 @@ namespace ts {
}
}
else {
Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function");
errorOrSuggestion(noImplicitAny, getter!, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
if (!isPrivateWithinAmbient(getter!)) {
errorOrSuggestion(noImplicitAny, getter!, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
}
}
type = anyType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ declare class Something
{
private static someStaticVar;
private someVar;
private get getter();
private set setter(v);
}

//// [app.ts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@ declare class Something

private someVar;
>someVar : Symbol(Something.someVar, Decl(test.d.ts, 2, 33))

private get getter();
>getter : Symbol(Something.getter, Decl(test.d.ts, 3, 20))

private set setter(v);
>setter : Symbol(Something.setter, Decl(test.d.ts, 4, 25))
>v : Symbol(v, Decl(test.d.ts, 5, 23))
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@ declare class Something

private someVar;
>someVar : any

private get getter();
>getter : any

private set setter(v);
>setter : any
>v : any
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ declare class Something
{
private static someStaticVar;
private someVar;
private get getter();
private set setter(v);
}

// @noimplicitany: true
Expand Down

0 comments on commit e0a286a

Please sign in to comment.