* Add type-only support for export declarations * Use a synthetic type alias instead of binding type-only exports as a type alias * Works for re-exports! * isolatedModules works fine * Diagnostic for type-only exporting a value * Start isolated modules codefix * Update for LKG control flow changes * Type-only import clause parsing * Type-only default import checking * Type-only named imports * Fix isolated modules error * Filter namespaces down to type-only * Fix class references * Test nested namespaces * Test circular type-only imports/exports * Fix getTypeAtLocation for type-only import/export specifiers * Fix type-only generic imports * Update public APIs * Remove unused WIP comment * Type-only namespace imports * Fix factory update calls * Add grammar errors for JS usage and mixing default and named bindings * Update updateExportDeclaration API baseline * Fix grammar checking import clauses * Enums, sort of * Dedicated error for type-only enum * Skip past type-only alias symbols in quick info * Update error code in baseline * WIP: convertToTypeOnlyExport * isolatedModules codefix (single export declaration) * isolatedModules code fix (all) * Stop eliding non-type-only imports by default, add compiler flag * Update to match updated diagnostic messages * Update more baselines * Update more tests * Auto-import as type-only * Add codefix for splitting type-only import with default and named bindings * Add more services tests * Add targeted error message for "export type T;" when T exists * Add targeted error for "import type T = require(...)" * Flip emit flag * Add test for preserveUnusedImports option * Fix flag flip on import = * Make compiler option string-valued * Fix merge conflicts * Add --importsNotUsedAsValue=error * Phrasing of messages. Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
40 lines
1,013 B
TypeScript
40 lines
1,013 B
TypeScript
/// <reference path="fourslash.ts" />
|
|
|
|
// @Filename: /a.ts
|
|
////export type B = {};
|
|
////export type C = {};
|
|
////export default interface A {}
|
|
|
|
// @Filename: /b.ts
|
|
////export type E = {};
|
|
////export type F = {};
|
|
////export default class D {}
|
|
|
|
// @Filename: /c.ts
|
|
////import type A, { B, C } from './a';
|
|
////import type D, * as types from './b';
|
|
|
|
goTo.file("/c.ts");
|
|
|
|
verify.codeFix({
|
|
errorCode: ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code,
|
|
description: ts.Diagnostics.Split_into_two_separate_import_declarations.message,
|
|
applyChanges: false,
|
|
index: 0,
|
|
newFileContent:
|
|
`import type A from './a';
|
|
import type { B, C } from './a';
|
|
import type D, * as types from './b';`
|
|
});
|
|
|
|
verify.codeFixAll({
|
|
fixId: "splitTypeOnlyImport",
|
|
fixAllDescription: ts.Diagnostics.Split_all_invalid_type_only_imports.message,
|
|
newFileContent:
|
|
`import type A from './a';
|
|
import type { B, C } from './a';
|
|
import type D from './b';
|
|
import type * as types from './b';
|
|
`
|
|
});
|