VS Code - JSON Schema缓存

时间:2015-07-21 11:43:41

标签: typescript visual-studio-code

我刚刚升级到TypeScript 1.5(不再是测试版),并且这样做,希望利用VS Code中的json架构助手。

配置tsconfig.json时,唯一的模块选项是commonjsamd,这意味着umdsystem基于此缺失:http://json.schemastore.org/tsconfig

我的问题是如何让VS Code刷新架构的缓存?

仅供参考,我已尝试覆盖设置中的URL并将其更改回来以及重新启动VS Code

2 个答案:

答案 0 :(得分:2)

  

我的问题是如何让VS Code刷新架构的缓存?

模式实际上是在名为jsonWorker.js的文件中进行硬编码(我的文件路径为C:\Users\basaratsyed\AppData\Local\Code\app-0.1.2\resources\app\client\vs\languages\json\jsonWorker.js),这个文件被缩小。以下是atom-beautify https://atom.io/packages/atom-beautify的相关代码美化

this.addPreloadedFileSchema("http://json.schemastore.org/tsconfig", {
            title: n.localize("vs_languages_json_jsonSchemaService", 110),
            $schema: "http://json-schema.org/draft-04/schema#",
            type: "object",
            default: {
                compilerOptions: {
                    target: "ES5",
                    module: "commonjs"
                }
            },
            properties: {
                compilerOptions: {
                    type: "object",
                    description: n.localize("vs_languages_json_jsonSchemaService", 111),
                    properties: {
                        charset: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 112),
                            type: "string"
                        },
                        declaration: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 113),
                            type: "boolean"
                        },
                        diagnostics: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 114),
                            type: "boolean"
                        },
                        emitBOM: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 115),
                            type: "boolean"
                        },
                        inlineSourceMap: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 116),
                            type: "number"
                        },
                        inlineSources: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 117),
                            type: "number"
                        },
                        listFiles: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 118),
                            type: "boolean"
                        },
                        locale: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 119),
                            type: "string"
                        },
                        mapRoot: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 120),
                            type: "string",
                            format: "uri"
                        },
                        module: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 121),
                            enum: ["commonjs", "amd"]
                        },
                        newLine: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 122),
                            type: "boolean"
                        },
                        noEmit: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 123),
                            type: "boolean"
                        },
                        noEmitOnError: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 124),
                            type: "boolean"
                        },
                        noEmitHelpers: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 125),
                            type: "boolean"
                        },
                        noImplicitAny: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 126),
                            type: "boolean"
                        },
                        noLib: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 127),
                            type: "boolean"
                        },
                        noResolve: {
                            type: "boolean"
                        },
                        out: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 128),
                            type: "string",
                            format: "uri"
                        },
                        outDir: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 129),
                            type: "string",
                            format: "uri"
                        },
                        preserveConstEnums: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 130),
                            type: "boolean"
                        },
                        removeComments: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 131),
                            type: "boolean"
                        },
                        rootDir: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 132),
                            type: "boolean"
                        },
                        sourceMap: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 133),
                            type: "boolean"
                        },
                        sourceRoot: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 134),
                            type: "string",
                            format: "uri"
                        },
                        suppressImplicitAnyIndexErrors: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 135),
                            type: "boolean"
                        },
                        target: {
                            description: n.localize("vs_languages_json_jsonSchemaService", 136),
                            enum: ["ES3", "ES5", "ES6", "es3", "es5", "es6"],
                            default: "ES3"
                        }
                    }
                },
                files: {
                    type: "array",
                    description: n.localize("vs_languages_json_jsonSchemaService", 137),
                    items: {
                        type: "string",
                        format: "uri"
                    }
                }
            }
        })

更专注于:

module: {
    description: n.localize("vs_languages_json_jsonSchemaService", 121),
    enum: ["commonjs", "amd"]
},

如果你改变它

module: {
    description: n.localize("vs_languages_json_jsonSchemaService", 121),
    enum: ["commonjs", "amd", "umd", "system"]
},

然后重新启动vs代码工作

enter image description here

请注意,在美化js文件之后,VS Code仍能正常工作;)

答案 1 :(得分:0)

  1. 我没有找到清除此类缓存的官方解决方案......但我认为命令“Reload Window”可以正常工作。
  2. “未反映对架构文件的更改”是一个错误https://github.com/Microsoft/vscode/issues/13897,并已修复。但据我所知,它要求模式文件的名称以“.json”结尾,任何其他扩展名称(例如我的情况下为“.schema”),甚至与设置中的json关联的明显,都不会触发刷新事件以使您的更改立即生效。