verbatim-module-syntax
NOTE: this rule is part of the
jsr
rule set.Enable full set in
deno.json
:{ "lint": { "rules": { "tags": ["jsr"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=jsr
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include
or exclude
array in deno.json
:{ "lint": { "rules": { "include": ["verbatim-module-syntax"], "exclude": ["verbatim-module-syntax"] } } }
强制类型导入声明为类型导入。
此规则确保当启用 verbatimModuleSyntax
TypeScript 编译器选项时,代码能够正常工作。这在分发 TypeScript 代码的库中非常有用,以便在更多场景中工作。
无效:
import { Person } from "./person.ts";
const person: Person = {
name: "David",
};
console.log(person);
import { output, Person } from "./person.ts";
const person: Person = {
name: "David",
};
output(person);
有效:
import type { Person } from "./person.ts";
const person: Person = {
name: "David",
};
console.log(person);
import { output, type Person } from "./person.ts";
const person: Person = {
name: "David",
};
output(person);