mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Fix error on interfaces in .js files (#35969)
* Use the correct error message. * Accepted baselines.
This commit is contained in:
committed by
GitHub
parent
82b0547281
commit
75ca64120f
@@ -1837,7 +1837,9 @@ namespace ts {
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics.Interface_declaration_cannot_have_implements_clause));
|
||||
const interfaceKeyword = tokenToString(SyntaxKind.InterfaceKeyword);
|
||||
Debug.assertDefined(interfaceKeyword);
|
||||
diagnostics.push(createDiagnosticForNode(node, Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
|
||||
return;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
const moduleKeyword = node.flags & NodeFlags.Namespace ? tokenToString(SyntaxKind.NamespaceKeyword) : tokenToString(SyntaxKind.ModuleKeyword);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Syntactic Diagnostics for file '/tests/cases/fourslash/getJavaScriptSyntacticDiagnostics6.ts':
|
||||
/tests/cases/fourslash/a.js(1,11): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
/tests/cases/fourslash/a.js(1,11): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
|
||||
==== /tests/cases/fourslash/a.js (1 errors) ====
|
||||
interface I { }
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
@@ -1,29 +1,29 @@
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(4,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(6,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(10,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(31,11): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(35,11): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(39,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(43,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(45,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(49,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(53,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(57,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(61,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(65,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(67,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(71,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(75,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(80,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(84,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(87,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(91,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(95,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(100,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(105,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(107,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(111,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(115,18): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(4,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(6,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(10,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(31,11): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(35,11): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(39,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(43,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(45,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(49,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(53,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(57,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(61,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(65,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(67,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(71,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(75,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(80,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(84,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(87,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(91,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(95,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(100,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(105,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(107,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(111,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
tests/cases/conformance/jsdoc/declarations/index.js(115,18): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsdoc/declarations/index.js (26 errors) ====
|
||||
@@ -32,17 +32,17 @@ tests/cases/conformance/jsdoc/declarations/index.js(115,18): error TS1176: Inter
|
||||
|
||||
export interface A {}
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
export interface B {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
cat: string;
|
||||
}
|
||||
|
||||
export interface C<T, U> {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
field: T & U;
|
||||
optionalField?: T;
|
||||
readonly readonlyField: T & U;
|
||||
@@ -65,135 +65,135 @@ tests/cases/conformance/jsdoc/declarations/index.js(115,18): error TS1176: Inter
|
||||
|
||||
interface G {}
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
export { G };
|
||||
|
||||
interface HH {}
|
||||
~~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
export { HH as H };
|
||||
|
||||
export interface I {}
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
export { I as II };
|
||||
|
||||
export { J as JJ };
|
||||
export interface J {}
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
export interface K extends I,J {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
x: string;
|
||||
}
|
||||
|
||||
export interface L extends K {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
y: string;
|
||||
}
|
||||
|
||||
export interface M<T> {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
field: T;
|
||||
}
|
||||
|
||||
export interface N<U> extends M<U> {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
other: U;
|
||||
}
|
||||
|
||||
export interface O {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: string;
|
||||
}
|
||||
|
||||
export interface P extends O {}
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
export interface Q extends O {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: "ok";
|
||||
}
|
||||
|
||||
export interface R extends O {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: number]: "ok";
|
||||
}
|
||||
|
||||
export interface S extends O {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: "ok";
|
||||
[idx: number]: never;
|
||||
}
|
||||
|
||||
export interface T {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: number]: string;
|
||||
}
|
||||
|
||||
export interface U extends T {}
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
|
||||
export interface V extends T {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: string;
|
||||
}
|
||||
|
||||
export interface W extends T {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: number]: "ok";
|
||||
}
|
||||
|
||||
export interface X extends T {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: string;
|
||||
[idx: number]: "ok";
|
||||
}
|
||||
|
||||
export interface Y {
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: {x: number};
|
||||
[idx: number]: {x: number, y: number};
|
||||
}
|
||||
|
||||
export interface Z extends Y {}
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
export interface AA extends Y {
|
||||
~~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: {x: number, y: number};
|
||||
}
|
||||
|
||||
export interface BB extends Y {
|
||||
~~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: number]: {x: 0, y: 0};
|
||||
}
|
||||
|
||||
export interface CC extends Y {
|
||||
~~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
[idx: string]: {x: number, y: number};
|
||||
[idx: number]: {x: 0, y: 0};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
|
||||
tests/cases/compiler/a.js(1,11): error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
tests/cases/compiler/a.js(1,11): error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
|
||||
|
||||
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
|
||||
@@ -8,4 +8,4 @@ tests/cases/compiler/a.js(1,11): error TS1176: Interface declaration cannot have
|
||||
==== tests/cases/compiler/a.js (1 errors) ====
|
||||
interface I { }
|
||||
~
|
||||
!!! error TS1176: Interface declaration cannot have 'implements' clause.
|
||||
!!! error TS8006: 'interface' declarations can only be used in TypeScript files.
|
||||
Reference in New Issue
Block a user