Skip to content

Commit 5272262

Browse files
ericbfadidahiya
authored andcommitted
[no-inferred-empty-object-type] Skip test in TS > 3.4.x (palantir#4661)
As the generic parameters are inferred as `unknown` in newer TS versions (> 3.4.x), this rule no longer applies in those versions, and those places that would have previously thrown an error, as seen in the tests, no longer should throw as they are no longer inferred as `{}`.
1 parent 2ca2f19 commit 5272262

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/rules/noInferredEmptyObjectTypeRule.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export class Rule extends Lint.Rules.TypedRule {
3030
options: null,
3131
optionExamples: [true],
3232
rationale: Lint.Utils.dedent`
33-
When function or constructor may be called with a type parameter but one isn't supplied or inferrable,
34-
TypeScript defaults to \`{}\`.
33+
Prior to TypeScript 3.4, generic type parameters for functions and constructors are inferred as
34+
\`{}\` (the empty object type) by default when no type parameter is explicitly supplied or when
35+
the compiler cannot infer a more specific type.
3536
This is often undesirable as the call is meant to be of a more specific type.
3637
`,
3738
type: "functionality",

test/rules/no-inferred-empty-object-type/test.ts.lint

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[typescript]: <=3.4.x
12
let s: string;
23
let n: number;
34
let o: Object;

0 commit comments

Comments
 (0)