schl3ck / ios-scriptable-types Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
I download the example directory and tried running the command npx eslint .
but there I'm getting the following error:
/scriptable/Welcome to Scriptable.js
57:18 error Parsing error: Unexpected token req
Is it not possible to use your files for eslint directly?
When I added the ESLint config to my project, ESLint stopped detecting uninitialized variables.
My Scriptable folder looks like this:
Scriptable Folder
├──jsconfig.json
├──package.json
├──Script.js
└──...
jsconfig.json
{
"compilerOptions": {
"lib": ["ES2021"],
"moduleDetection": "force"
}
}
package.json
{
"name": "scriptable",
"version": "1.0.0",
"eslintConfig": {
"extends": "@scriptable-ios",
"rules": {
"no-unused-vars": "warn"
},
"parserOptions": { // workaround for top level await
"ecmaVersion": "latest",
"sourceType": "module"
}
},
"devDependencies": {
"@scriptable-ios/eslint-config": "latest",
"@types/scriptable-ios": "latest",
"eslint": "latest"
}
}
There still is IntelliSense for Scriptable API, unused-vars, ... but missing errors for uninitialized vars.
Hey, love the project! I finally switched over to your library after having maintained my own version for years.
I know this issue is not your fault, since these typings are automatically generated from the docs, but though I'd flag it anyway.
notes
, dueDate
, and completionDate
can all be falsy, and are by default. You can confirm this by running the following code in Scriptable:
const r = new Reminder();
console.log(JSON.stringify({
notes: String(r.notes),
dueDate: String(r.dueDate),
completionDate: String(r.completionDate)
}, null, 2));
Which results in this:
{
"notes": "undefined",
"dueDate": "null",
"completionDate": "null"
}
But your package, and the Scriptable docs, show all those values as never being falsy.
I've fixed this in my own codebase w/ the following type declaration:
declare class AdjustedReminder extends Reminder {
notes?: string;
dueDate?: Date;
completionDate?: Date;
}
And then I just use AdjustedReminder
anywhere I'd otherwise use Reminder
(as a type).
I am currently trying to code a Scriptable script with typescript
, webpack
, and schl3ck/ios-scriptable-types
. However, as I tried to create a new Request
, Typescript IntelliSense used the node.js Request instead of the Scriptable Request for linting.
This is not specifically an issue with this repo, but rather a problem with how VSCode IntelliSense handles the naming conflict of the built-in node.js Request and the Scriptable Request. I am not asking for a fix by this repo owner (because I think there is none), but rather if you know how to fix this issue.
I can also just // @ts-ignore
the line, but this will give me an any
type, which I don't want to do.
./.eslintrc
{
"root": true,
"env": {
"es2022": true,
"jest": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["plugin:@typescript-eslint/recommended", "@scriptable-ios"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {}
}
./jsconfig.json
{
"compilerOptions": {
"lib": ["ES2021"],
"moduleDetection": "force"
}
}
./tsconfig.json
{
"compilerOptions": {
"module": "CommonJS",
"target": "es2017",
"outDir": "./dist",
"noImplicitAny": true,
"skipLibCheck": true
},
"include": ["./src/package/**/*"]
}
./package.json
{
"name": "spm-package",
"type": "module",
"scripts": {
"build": "npx webpack --mode=production --node-env=production",
"watch": "npx webpack --mode=development --node-env=development --watch",
"test": "npx jest"
},
"devDependencies": {
"@scriptable-ios/eslint-config": "^1.7.0",
"@types/scriptable-ios": "latest",
"@typescript-eslint/eslint-plugin": "^5.46.0",
"@typescript-eslint/parser": "^5.46.0",
"eslint": "latest",
"eslint-webpack-plugin": "^3.2.0",
"jest": "^29.3.1",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
}
}
./src/package/Package.ts
export default class Package {
author: string;
name: string;
version: string;
description: string;
fileData: string | null;
constructor(author: string, name: string, version: string) {
this.author = author;
this.name = name;
this.version = version;
}
async fetchPackageInfo() {
const url = ``;
const data = await new Request(url).loadJSON();
}
}
The Request type used by IntelliSense is located at
/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts
Hey—I think you've done some valuable work here!
From the readme:
I don't know how to publish this. I've thought about DefinitlyTyped. But then you need to have npm and a node_modules folder in the working dorectory. Or should I make a VisualStudio Code Extension? (But that would take some time)
If you have any idea, just open an issue.
I see a lot of benefit from making the content of this project consumable as modules.
A listing in DefinitelyTyped as well as an ESLint shareable config would provide complementary functionality.
I propose the namespace scriptable-ios
so it could be
@types/scriptable-ios
and @scriptable-ios/eslint-config
. I have created a pull request with an example, which you can explore.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.